package hos.permission;

import android.Manifest;
import android.os.Build;

import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>Title: PermissionConstants </p>
 * <p>Description: 权限常量 </p>
 * <p>Company: www.mapuni.com </p>
 *
 * @author : 蔡俊峰
 * @version : 1.0
 * @date : 2024-01-03 22:20
 */
public final class PermissionConstants {

    private PermissionConstants() {
    }

    @NonNull
    public static String ACCESS_BACKGROUND_LOCATION = "android.permission.ACCESS_BACKGROUND_LOCATION";
    @NonNull
    public static String MANAGE_EXTERNAL_STORAGE = "android.permission.MANAGE_EXTERNAL_STORAGE";
    @NonNull
    public static String REQUEST_INSTALL_PACKAGES = "android.permission.REQUEST_INSTALL_PACKAGES";
    @NonNull
    public static String POST_NOTIFICATIONS = "android.permission.POST_NOTIFICATIONS";
    @NonNull
    public static String BODY_SENSORS_BACKGROUND = "android.permission.BODY_SENSORS_BACKGROUND";
    /**
     * Maintains all the special permissions that we need to handle by special case.
     */
    @NonNull
    public static String[] allSpecialPermissions = {
            ACCESS_BACKGROUND_LOCATION,
            Manifest.permission.SYSTEM_ALERT_WINDOW,
            Manifest.permission.WRITE_SETTINGS,
            MANAGE_EXTERNAL_STORAGE,
            REQUEST_INSTALL_PACKAGES,
            POST_NOTIFICATIONS,
            BODY_SENSORS_BACKGROUND
    };

    @NonNull
    @RequiresApi(api = Build.VERSION_CODES.Q)
    public static Map<String, String> permissionMapOnQ() {
        Map<String, String> permissionMapOnQ = new HashMap<String, String>();
        permissionMapOnQ.put(Manifest.permission.READ_CALENDAR, Manifest.permission_group.CALENDAR);
        permissionMapOnQ.put(Manifest.permission.WRITE_CALENDAR, Manifest.permission_group.CALENDAR);
        permissionMapOnQ.put(Manifest.permission.READ_CALL_LOG, Manifest.permission_group.CALL_LOG);
        permissionMapOnQ.put(Manifest.permission.WRITE_CALL_LOG, Manifest.permission_group.CALL_LOG);
        permissionMapOnQ.put("android.permission.PROCESS_OUTGOING_CALLS", Manifest.permission_group.CALL_LOG);
        permissionMapOnQ.put(Manifest.permission.CAMERA, Manifest.permission_group.CAMERA);
        permissionMapOnQ.put(Manifest.permission.READ_CONTACTS, Manifest.permission_group.CONTACTS);
        permissionMapOnQ.put(Manifest.permission.WRITE_CONTACTS, Manifest.permission_group.CONTACTS);
        permissionMapOnQ.put(Manifest.permission.GET_ACCOUNTS, Manifest.permission_group.CONTACTS);
        permissionMapOnQ.put(Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission_group.LOCATION);
        permissionMapOnQ.put(Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission_group.LOCATION);
        permissionMapOnQ.put(Manifest.permission.ACCESS_BACKGROUND_LOCATION, Manifest.permission_group.LOCATION);
        permissionMapOnQ.put(Manifest.permission.RECORD_AUDIO, Manifest.permission_group.MICROPHONE);
        permissionMapOnQ.put(Manifest.permission.READ_PHONE_STATE, Manifest.permission_group.PHONE);
        permissionMapOnQ.put(Manifest.permission.READ_PHONE_NUMBERS, Manifest.permission_group.PHONE);
        permissionMapOnQ.put(Manifest.permission.CALL_PHONE, Manifest.permission_group.PHONE);
        permissionMapOnQ.put(Manifest.permission.ANSWER_PHONE_CALLS, Manifest.permission_group.PHONE);
        permissionMapOnQ.put(Manifest.permission.ADD_VOICEMAIL, Manifest.permission_group.PHONE);
        permissionMapOnQ.put(Manifest.permission.USE_SIP, Manifest.permission_group.PHONE);
        permissionMapOnQ.put(Manifest.permission.ACCEPT_HANDOVER, Manifest.permission_group.PHONE);
        permissionMapOnQ.put(Manifest.permission.BODY_SENSORS, Manifest.permission_group.SENSORS);
        permissionMapOnQ.put(Manifest.permission.ACTIVITY_RECOGNITION, Manifest.permission_group.ACTIVITY_RECOGNITION);
        permissionMapOnQ.put(Manifest.permission.SEND_SMS, Manifest.permission_group.SMS);
        permissionMapOnQ.put(Manifest.permission.RECEIVE_SMS, Manifest.permission_group.SMS);
        permissionMapOnQ.put(Manifest.permission.READ_SMS, Manifest.permission_group.SMS);
        permissionMapOnQ.put(Manifest.permission.RECEIVE_WAP_PUSH, Manifest.permission_group.SMS);
        permissionMapOnQ.put(Manifest.permission.RECEIVE_MMS, Manifest.permission_group.SMS);
        permissionMapOnQ.put(Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission_group.STORAGE);
        permissionMapOnQ.put(Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission_group.STORAGE);
        permissionMapOnQ.put(Manifest.permission.ACCESS_MEDIA_LOCATION, Manifest.permission_group.STORAGE);
        return permissionMapOnQ;
    }

    @NonNull
    @RequiresApi(api = Build.VERSION_CODES.R)
    public static Map<String, String> permissionMapOnR() {
        Map<String, String> permissionMapOnR = permissionMapOnQ();
        permissionMapOnR.put(Manifest.permission.MANAGE_EXTERNAL_STORAGE, Manifest.permission_group.STORAGE);
        return permissionMapOnR;
    }

    @NonNull
    @RequiresApi(api = Build.VERSION_CODES.S)
    public static Map<String, String> permissionMapOnS() {
        Map<String, String> permissionMapOnS = permissionMapOnR();
        permissionMapOnS.put(Manifest.permission.BLUETOOTH_SCAN, Manifest.permission_group.NEARBY_DEVICES);
        permissionMapOnS.put(Manifest.permission.BLUETOOTH_ADVERTISE, Manifest.permission_group.NEARBY_DEVICES);
        permissionMapOnS.put(Manifest.permission.BLUETOOTH_CONNECT, Manifest.permission_group.NEARBY_DEVICES);
        return permissionMapOnS;
    }

    @NonNull
    @RequiresApi(api = Build.VERSION_CODES.TIRAMISU)
    public static Map<String, String> permissionMapOnT() {
        Map<String, String> permissionMapOnT = permissionMapOnS();
        permissionMapOnT.put(Manifest.permission.READ_MEDIA_IMAGES, Manifest.permission_group.READ_MEDIA_VISUAL);
        permissionMapOnT.put(Manifest.permission.READ_MEDIA_VIDEO, Manifest.permission_group.READ_MEDIA_VISUAL);
        permissionMapOnT.put(Manifest.permission.READ_MEDIA_AUDIO, Manifest.permission_group.READ_MEDIA_AURAL);
        permissionMapOnT.put(Manifest.permission.POST_NOTIFICATIONS, Manifest.permission_group.NOTIFICATIONS);
        permissionMapOnT.put(Manifest.permission.NEARBY_WIFI_DEVICES, Manifest.permission_group.NEARBY_DEVICES);
        permissionMapOnT.put(Manifest.permission.BODY_SENSORS_BACKGROUND, Manifest.permission_group.SENSORS);
        return permissionMapOnT;
    }

    @NonNull
    public static final String[] GROUP_CALENDAR = {
            Manifest.permission.READ_CALENDAR, Manifest.permission.WRITE_CALENDAR
    };
    @NonNull
    public static final String[] GROUP_CAMERA = {
            Manifest.permission.CAMERA
    };
    @NonNull
    public static final String[] GROUP_CONTACTS = {
            Manifest.permission.READ_CONTACTS, Manifest.permission.WRITE_CONTACTS, Manifest.permission.GET_ACCOUNTS
    };
    @NonNull
    public static final String[] GROUP_LOCATION = {
            Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION
    };
    @NonNull
    @RequiresApi(api = Build.VERSION_CODES.Q)
    public static final String[] GROUP_LOCATION_BACKGROUND = {
            Manifest.permission.ACCESS_BACKGROUND_LOCATION
    };
    @NonNull
    @RequiresApi(api = Build.VERSION_CODES.Q)
    public static final String[] GROUP_LOCATION_ALL = {
            Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_BACKGROUND_LOCATION
    };
    @NonNull
    public static final String[] GROUP_AUDIO = {
            Manifest.permission.RECORD_AUDIO
    };
    @NonNull
    @RequiresApi(api = Build.VERSION_CODES.TIRAMISU)
    public static final String[] GROUP_AUDIO_33 = {
            Manifest.permission.RECORD_AUDIO, Manifest.permission.READ_MEDIA_AUDIO, Manifest.permission.READ_EXTERNAL_STORAGE,
    };
    @NonNull
    public static final String[] GROUP_PHONE = {
            Manifest.permission.READ_PHONE_STATE, Manifest.permission.CALL_PHONE,
            Manifest.permission.READ_CALL_LOG, Manifest.permission.WRITE_CALL_LOG, Manifest.permission.ADD_VOICEMAIL,
            Manifest.permission.USE_SIP, Manifest.permission.PROCESS_OUTGOING_CALLS
    };
    @NonNull
    @RequiresApi(api = Build.VERSION_CODES.O)
    public static final String[] GROUP_PHONE_BELOW_O = {
            Manifest.permission.READ_PHONE_STATE, Manifest.permission.READ_PHONE_NUMBERS, Manifest.permission.CALL_PHONE,
            Manifest.permission.READ_CALL_LOG, Manifest.permission.WRITE_CALL_LOG, Manifest.permission.ADD_VOICEMAIL,
            Manifest.permission.USE_SIP, Manifest.permission.PROCESS_OUTGOING_CALLS, Manifest.permission.ANSWER_PHONE_CALLS
    };
    @NonNull
    @RequiresApi(api = Build.VERSION_CODES.KITKAT_WATCH)
    public static final String[] GROUP_SENSORS = {
            Manifest.permission.BODY_SENSORS
    };
    @NonNull
    public static final String[] GROUP_SMS = {
            Manifest.permission.SEND_SMS, Manifest.permission.RECEIVE_SMS, Manifest.permission.READ_SMS,
            Manifest.permission.RECEIVE_WAP_PUSH, Manifest.permission.RECEIVE_MMS,
    };
    @NonNull
    public static final String[] GROUP_STORAGE = {
            Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE,
    };
    @NonNull
    @RequiresApi(api = Build.VERSION_CODES.R)
    public static final String[] GROUP_STORAGE_MANAGE = {
            Manifest.permission.MANAGE_EXTERNAL_STORAGE,
    };
    @NonNull
    @RequiresApi(api = Build.VERSION_CODES.TIRAMISU)
    public static final String[] GROUP_IMAGES = {
            Manifest.permission.READ_MEDIA_IMAGES, Manifest.permission.READ_EXTERNAL_STORAGE,
    };
    @NonNull
    @RequiresApi(api = Build.VERSION_CODES.TIRAMISU)
    public static final String[] GROUP_VIDEO = {
            Manifest.permission.READ_MEDIA_VIDEO, Manifest.permission.READ_EXTERNAL_STORAGE,
    };
    @NonNull
    @RequiresApi(api = Build.VERSION_CODES.TIRAMISU)
    public static final String[] GROUP_STORAGE_33 = {
            Manifest.permission.READ_MEDIA_VIDEO, Manifest.permission.READ_MEDIA_IMAGES, Manifest.permission.READ_MEDIA_AUDIO
    };
    @NonNull
    @RequiresApi(api = Build.VERSION_CODES.TIRAMISU)
    public static final String[] GROUP_STORAGE_ALL = {
            Manifest.permission.READ_MEDIA_VIDEO, Manifest.permission.READ_MEDIA_IMAGES, Manifest.permission.READ_MEDIA_AUDIO,
            Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE
    };
    @NonNull
    public static final String[] GROUP_CAMERA_STORAGE = {
            Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE,
    };
    @NonNull
    @RequiresApi(api = Build.VERSION_CODES.Q)
    public static final String[] GROUP_ACTIVITY_RECOGNITION = {
            Manifest.permission.ACTIVITY_RECOGNITION,
    };
    @NonNull
    @RequiresApi(api = Build.VERSION_CODES.TIRAMISU)
    public static final String[] GROUP_POST_NOTIFICATIONS = {
            Manifest.permission.POST_NOTIFICATIONS,
    };

}
